package com.zxf.orderservice.service;

import com.zxf.orderservice.feign.CreateService;
import com.zxf.orderservice.feign.StockService;
import com.zxf.orderservice.feign.WmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService{

    @Autowired
    private CreateService createService;
    @Autowired
    private StockService stockService;
    @Autowired
    private WmsService wmsService;

//    @Transactional
    public String createOrder(Long productId, Long userId, Integer stockCount, Integer creditCount){
        System.out.println("创建订单成功");
        stockService.deductStock(productId,stockCount);
        createService.addCredit(userId,creditCount);
        wmsService.delivery(userId, productId);
        System.out.println("订单完成");
        return "success";
    }
}
